import service from '@/core/net/request'
import { queryParams } from '@/core/utils/tools'
interface LoginParams {
  username: string
  password: string
}
export const login = (params: LoginParams) => {
  return service.post('/api/admin/login', params)
}
export const getinfo = () => {
  return service.post('/api/admin/getinfo')
}

export function getUserList(page, query = {}) {
  const r = queryParams(query)
  return service.get(`/api/admin/user/${page}${r}`)
}

export function updateUserStatus(id, status) {
  return service.post(`/api/admin/user/${id}/update_status`, {
    status,
  })
}

export function createUser(data) {
  return service.post(`/api/admin/user`, data)
}

export function updateUser(id, data) {
  return service.post(`/api/admin/user/${id}`, data)
}

export function deleteUser(id) {
  return service.post(`/api/admin/user/${id}/delete`)
}
